//
//  MoneyFooter.m
//  JinChengYun
//
//  Created by 金橙云 on 2017/4/7.
//  Copyright © 2017年 金橙云. All rights reserved.
//
#define QA 15
#define QB (Q_WIDTH-QA*5)/4
#define Q_WIDTH self.frame.size.width

#define S_Lab (Q_WIDTH/4)

#import "MoneyFooter.h"

@implementation MoneyFooter

-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        
        //2 接收通知
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(acceptNotific:) name:@"ValueDic" object:nil];

        _chuanDic = [NSMutableDictionary dictionary];
        _zhuHDic = [NSMutableDictionary dictionary];
         _busHDic = [NSMutableDictionary dictionary];
         _peiHDic = [NSMutableDictionary dictionary];
        _ZHDic = [NSMutableDictionary dictionary];
        
      
        [self setupFooter];
    }
    return self;
}



-(void)setupFooter
{
   // _qianBiaoLab = [[UILabel alloc] init];
    
    UILabel *oLab = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, Q_WIDTH, 0.5)];
    oLab.backgroundColor = [UIColor grayColor];
    [self addSubview:oLab];
    _qianLab = [[UILabel alloc] init];
    _qianLab.backgroundColor = [UIColor orangeColor];
    _qianLab.font = [UIFont systemFontOfSize:14];
    _qianLab.text = @"   欠款数据(单位:万元)";
    _qianLab.textColor = [UIColor whiteColor];
    [self addSubview:_qianLab];
    [_qianLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(Q_WIDTH, 25));
        make.left.equalTo(self.mas_left).offset(0);
        make.top.equalTo(self.mas_top).offset(5);
    }];
    
    
    NSArray *arr = @[@"类别",@"首付欠款",@"贷款欠款",@"合计"];
    for (int i= 0; i<4; i++)
    {
        UILabel *firstLab = [[UILabel alloc] init];
        firstLab.frame = CGRectMake(QA+(20+QB)*i, 35,QB, 20);
        firstLab.textAlignment = NSTextAlignmentCenter;
        firstLab.font = [UIFont systemFontOfSize:12];
        firstLab.text = arr[i];
        [self addSubview:firstLab];
        
    }
    
    for (int a = 0; a<6; a++)
    {
        UILabel *lineLab = [[UILabel alloc] init];
        lineLab.frame = CGRectMake(0, 30+30*a, Q_WIDTH, 0.5f);
        lineLab.backgroundColor = [UIColor blackColor];
        [self addSubview:lineLab];
    }
    
    NSArray *arr1 = @[@"主售房源",@"商业房源",@"配套房源",@"合计"];
    for (int b = 0; b<4; b++)
    {
        UILabel *shuLab = [[UILabel alloc] init];
        shuLab.frame = CGRectMake(QA, 65+30*b, QB, 20);
        shuLab.textAlignment = NSTextAlignmentCenter;
        shuLab.font = [UIFont systemFontOfSize:12];
        shuLab.text = arr1[b];
        [self addSubview:shuLab];
        
    }
    
    //竖线
    for (int s= 0; s<3; s++)
    {
        _shuLab = [[UILabel alloc] init];
        _shuLab.backgroundColor = [UIColor blackColor];
        _shuLab.frame = CGRectMake(S_Lab+S_Lab*s, 30, 0.5f, 150);
        [self addSubview:_shuLab];
        
    }
    
    
    
    
    
    //主售房源---首付欠款--贷款欠款--合计
    _zhuSFLab = [[UILabel alloc] init];
    _zhuSFLab.text = @"23224u823";
    _zhuSFLab.textColor = [UIColor orangeColor];
    _zhuSFLab.textAlignment = NSTextAlignmentCenter;
    _zhuSFLab.font = [UIFont systemFontOfSize:12];
    [self addSubview:_zhuSFLab];
    [_zhuSFLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(QB, 20));
        make.left.equalTo(self.mas_left).offset(2*QA+QB);
        make.top.equalTo(self.mas_top).offset(65);
    }];
    
    _zhuDKLab = [[UILabel alloc] init];
    _zhuDKLab.text = @"23224u823";
    _zhuDKLab.textColor = [UIColor orangeColor];
    _zhuDKLab.textAlignment = NSTextAlignmentCenter;
    _zhuDKLab.font = [UIFont systemFontOfSize:12];
    [self addSubview:_zhuDKLab];
    [_zhuDKLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(QB, 20));
        make.left.equalTo(_zhuSFLab.mas_right).offset(QA);
        make.top.equalTo(self.mas_top).offset(65);
    }];

    _zhuHLab = [[UILabel alloc] init];
    _zhuHLab.text = @"23224u823";
    _zhuHLab.textColor = [UIColor orangeColor];
    _zhuHLab.textAlignment = NSTextAlignmentCenter;
    _zhuHLab.font = [UIFont systemFontOfSize:12];
    [self addSubview:_zhuHLab];
    [_zhuHLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(QB, 20));
        make.left.equalTo(_zhuDKLab.mas_right).offset(QA);
        make.top.equalTo(self.mas_top).offset(65);
    }];


     //商业房源---首付欠款--贷款欠款--合计
    _busSFLab =  [[UILabel alloc] init];
    _busSFLab.text = @"23224u823";
    _busSFLab.textColor = [UIColor orangeColor];
    _busSFLab.textAlignment = NSTextAlignmentCenter;
    _busSFLab.font = [UIFont systemFontOfSize:12];
    [self addSubview:_busSFLab];
    [_busSFLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(QB, 20));
        make.left.equalTo(self.mas_left).offset(2*QA+QB);
        make.top.equalTo(self.mas_top).offset(95);
    }];

    _busDKLab = [[UILabel alloc] init];
    _busDKLab.text = @"03224u823";
    _busDKLab.textColor = [UIColor orangeColor];
    _busDKLab.textAlignment = NSTextAlignmentCenter;
    _busDKLab.font = [UIFont systemFontOfSize:12];
    [self addSubview:_busDKLab];
    [_busDKLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(QB, 20));
        make.left.equalTo(_busSFLab.mas_right).offset(QA);
        make.top.equalTo(self.mas_top).offset(95);
    }];

    
    _busHLab = [[UILabel alloc] init];
    _busHLab.text = @"93224u823";
    _busHLab.textColor = [UIColor orangeColor];
    _busHLab.textAlignment = NSTextAlignmentCenter;
    _busHLab.font = [UIFont systemFontOfSize:12];
    [self addSubview:_busHLab];
    [_busHLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(QB, 20));
        make.left.equalTo(_busDKLab.mas_right).offset(QA);
        make.top.equalTo(self.mas_top).offset(95);
    }];

    
     //配套房源---首付欠款--贷款欠款--合计
    _peiSFLab = [[UILabel alloc] init];
    _peiSFLab.text = @"3224u823";
    _peiSFLab.textColor = [UIColor orangeColor];
    _peiSFLab.textAlignment = NSTextAlignmentCenter;
    _peiSFLab.font = [UIFont systemFontOfSize:12];
    [self addSubview:_peiSFLab];
    [_peiSFLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(QB, 20));
        make.left.equalTo(self.mas_left).offset(2*QA+QB);
        make.top.equalTo(self.mas_top).offset(125);
    }];

    
    _peiDKLab = [[UILabel alloc] init];
    _peiDKLab.text = @"03224u823";
    _peiDKLab.textColor = [UIColor orangeColor];
    _peiDKLab.textAlignment = NSTextAlignmentCenter;
    _peiDKLab.font = [UIFont systemFontOfSize:12];
    [self addSubview:_peiDKLab];
    [_peiDKLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(QB, 20));
        make.left.equalTo(_peiSFLab.mas_right).offset(QA);
        make.top.equalTo(self.mas_top).offset(125);
    }];
    
    
    _peiHLab = [[UILabel alloc] init];
    _peiHLab.text = @"93224u823";
    _peiHLab.textColor = [UIColor orangeColor];
    _peiHLab.textAlignment = NSTextAlignmentCenter;
    _peiHLab.font = [UIFont systemFontOfSize:12];
    [self addSubview:_peiHLab];
    [_peiHLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(QB, 20));
        make.left.equalTo(_peiDKLab.mas_right).offset(QA);
        make.top.equalTo(self.mas_top).offset(125);
    }];
    

    //最下边一行的合计  首付欠款合计
    _shouHLab = [[UILabel alloc] init];
    _shouHLab.text = @"pppp";
    _shouHLab.textColor = [UIColor orangeColor];
    _shouHLab.textAlignment = NSTextAlignmentCenter;
    _shouHLab.font = [UIFont systemFontOfSize:12];
    [self addSubview:_shouHLab];
    [_shouHLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(QB, 20));
        make.left.equalTo(self.mas_left).offset(2*QA+QB);
        make.top.equalTo(self.mas_top).offset(155);
    }];
    
    
    _daiHLab = [[UILabel alloc] init];
    _daiHLab.text = @"wwwww";
    _daiHLab.textColor = [UIColor orangeColor];
    _daiHLab.textAlignment = NSTextAlignmentCenter;
    _daiHLab.font = [UIFont systemFontOfSize:12];
    [self addSubview:_daiHLab];
    [_daiHLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(QB, 20));
        make.left.equalTo(_peiSFLab.mas_right).offset(QA);
        make.top.equalTo(self.mas_top).offset(155);
    }];

    _heLab = [[UILabel alloc] init];
    _heLab.text = @"93224u823";
    _heLab.textColor = [UIColor orangeColor];
    _heLab.textAlignment = NSTextAlignmentCenter;
    _heLab.font = [UIFont systemFontOfSize:12];
    [self addSubview:_heLab];
    [_heLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(QB, 20));
        make.left.equalTo(_peiDKLab.mas_right).offset(QA);
        make.top.equalTo(self.mas_top).offset(155);
    }];
    

    
    
}

-(void)acceptNotific:(NSNotification *)notifica
{
    _chuanDic = notifica.object;
   // NSLog(@"--------_chuanDic---------%@",_chuanDic);

  
    _zhuHDic = [_chuanDic objectForKey:@"zs_qian"];
    _busHDic = [_chuanDic objectForKey:@"sy_qian"];
    _peiHDic = [_chuanDic objectForKey:@"pt_qian"];
    _ZHDic = [_chuanDic objectForKey:@"hj_qian"];
    
    
    _zhuSFLab.text = [_zhuHDic objectForKey:@"sf_qian"];
    _zhuDKLab.text = [_zhuHDic objectForKey:@"loan_qian"];
    _zhuHLab.text = [_zhuHDic objectForKey:@"heji"];
    
    _busSFLab.text = [_busHDic objectForKey:@"sf_qian"];
    _busDKLab.text = [_busHDic objectForKey:@"loan_qian"];
    _busHLab.text = [_busHDic objectForKey:@"heji"];

    _peiSFLab.text = [_peiHDic objectForKey:@"sf_qian"];
    _peiDKLab.text = [_peiHDic objectForKey:@"loan_qian"];
    _peiHLab.text = [_peiHDic objectForKey:@"heji"];
    
    
    _shouHLab.text = [_ZHDic objectForKey:@"sf_qian"];
    _daiHLab.text = [_ZHDic objectForKey:@"loan_qian"];
    _heLab.text = [_ZHDic objectForKey:@"heji"];
    

    
    
    
}
@end
